package com.rimi.impl;


import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.rimi.bean.Page;
import com.rimi.bean.Shop;
import com.rimi.bean.ShopExample;
import com.rimi.mapper.ShopMapper;
import com.rimi.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: ECsystem
 * @Date: 2018/9/17 18:39
 * @Author: Mr.GuoQiang
 * @Description:
 */
/* 代表当前这个类属于业务层service层 */
@Service
public class ShopServiceImpl implements ShopService {

//    @Resource(name = "shopMapper")
    @Autowired
    private ShopMapper shopMapper;

    @Override
    public List<Shop> getShopList(Shop shop, Page page) {
        System.out.println("*****************");
        //构建查询条件
        ShopExample example = new ShopExample();
        System.out.println(page.getNowPage()+"---"+page.getPageSize());
        System.out.println("*****************startPage  "+shopMapper+"-----");
        //调用分页方法
        PageHelper.startPage(page.getNowPage(),page.getPageSize());
        //调用查询方法
        List<Shop> shops = shopMapper.selectByExample(example);
        System.out.println("*****************selectByExample"+shops);
        //

        return shops;
    }

    @Override
    public Shop getShopById(Integer id) {
        return shopMapper.selectByPrimaryKey(id);
    }


}

